<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>猫武士起名生成器</title>
    <!-- 使用CDN加载Bootstrap和jQuery -->
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/bootswatch/4.4.1/cosmo/bootstrap.min.css?v=1.0">
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js?v=1.0"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js?v=1.0"></script>
    <style>
        body {
            font-family: '宋体', sans-serif;
            background: linear-gradient(135deg, #ececec, #f5f5f5);
            background-size: cover;
            background-repeat: no-repeat;
            background-attachment: fixed;
            padding: 20px;
        }
        .navbar {
            background-color: #fff;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            border-radius: 12px;
        }
        .container {
            background-color: #fff;
            padding: 20px;
            border-radius: 12px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            margin-top: 20px;
        }
        h1 {
            color: #004085;
            font-weight: bold;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
        }
        .btn-primary {
            background-color: #007bff;
            border: none;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            border-radius: 12px;
        }
        .btn-primary:hover {
            background-color: #0056b3;
        }
        .custom-switch {
            margin-bottom: 10px;
        }
        .custom-switch .custom-control-label {
            color: #004085;
        }
    </style>
     <script>
        document.addEventListener('DOMContentLoaded', function () {
            const script3 = document.createElement('script');
            script3.src = "../data/zh-cn.js?v=1.0";
            document.body.appendChild(script3);

            script3.onload = function () {
                // JavaScript代码部分
            };
        });
    </script>
</head>
<body>
    <header class="mb-5">
        <nav class="navbar navbar-expand-lg navbar-light">
            <a class="navbar-brand" href="./">猫武士起名生成器</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarSupportedContent">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="../en/">Return to Home</a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            Language
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                            <a class="dropdown-item" href="../zh-cn/">中文（中国大陆）</a>
                            <a class="dropdown-item" href="../zh-tw/">中文（台灣）</a>
                            <a class="dropdown-item" href="../en/">English</a>
                        </div>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="https://gitlab.com/Qinshihuang233/warriors-name">Project Address</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="./about-en/">关于</a>
                    </li>
                </ul>
            </div>
        </nav>
    </header>

    
    <main role="main" class="container">
      <h1>关于</h1>
      <p>一个基于艾琳 · 亨特所著的《猫武士》系列小说的族群猫名生成器。本站先为开源代码：https://github.com/nminnow/warriors-name-generator，后经过Qinshihuang233（我）再次更新在master分支并维护而成本站现行代码。（https://gitlab.com/Qinshihuang233/warriors-name）/</p>
      <p>数据收集自<a href="https://crystalpool.cxuesong.com/">水晶池</a>并经过处理，本页面最后更新于<span id="lastUpdated"></span>。</p>
    </main>

    <script src="../../about-cn/aboutcn.html"></script>
        <script>
        document.addEventListener('DOMContentLoaded', function () {
            const script1 = document.createElement('script');
            script1.src = "https://code.jquery.com/jquery-3.4.1.slim.min.js";
            document.body.appendChild(script1);

            const script2 = document.createElement('script');
            script2.src = "https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js";
            document.body.appendChild(script2);

            const script3 = document.createElement('script');
            script3.src = "../data/zh-cn.js";
            document.body.appendChild(script3);

            script3.onload = function () {
                const basePrefixes = data.prefixes;
                const baseSuffixes = data.suffixes;
                const totalApprentices = data.apprentices;
                const totalKits = data.kits;
                const unweightedPrefixes = [...new Set(basePrefixes)];
                const unweightedSuffixes = [...new Set(baseSuffixes)];
                let prefixes = basePrefixes;
                let suffixes = baseSuffixes;
                let includeUnderageCheckbox = document.getElementById("includeUnderage");
                let ignoreWeightingCheckbox = document.getElementById("ignoreWeighting");

                function changeIncludeUnderage() {
                    if (includeUnderageCheckbox.checked) {
                        ignoreWeightingCheckbox.disabled = false;
                    } else {
                        ignoreWeightingCheckbox.disabled = false;
                    }
                }

                function changeIgnoreWeighting() {
                    if (ignoreWeightingCheckbox.checked) {
                        includeUnderageCheckbox.disabled = false;
                        prefixes = unweightedPrefixes;
                        suffixes = unweightedSuffixes;
                    } else {
                        includeUnderageCheckbox.disabled = false;
                        prefixes = basePrefixes;
                        suffixes = baseSuffixes;
                    }
                }

                function generateName() {
                    let prefix = prefixes[Math.floor(Math.random() * prefixes.length)];
                    let suffix;
                    let kit = false;
                    let randomIndex;
                    if (includeUnderageCheckbox.checked) {
                        randomIndex = Math.floor(Math.random() * (suffixes.length + totalApprentices + totalKits));
                        if (randomIndex < suffixes.length) {
                            suffix = suffixes[randomIndex];
                        } else if (randomIndex < suffixes.length + totalApprentices) {
                            suffix = "爪";
                        } else {
                            kit = true;
                        }
                    } else {
                        suffix = suffixes[Math.floor(Math.random() * suffixes.length)];
                    }
                    const name = kit ? "小" + prefix : prefix + suffix;
                    document.getElementById("displayName").innerHTML = name;
                }

                includeUnderageCheckbox.addEventListener('click', changeIncludeUnderage);
                ignoreWeightingCheckbox.addEventListener('click', changeIgnoreWeighting);
                document.querySelector('.btn-primary').addEventListener('click', generateName);
            };
        });
    </script>
</body>
</html>